package com.cskaoyan.bean;

/**
 * 线程安全的单例
 */
public class MySingleton2 {

    private static MySingleton2 mySingleton;
    //私有构造方法
    private MySingleton2() {
    }

    public static synchronized MySingleton2 getInstance() {
        //实例化一次
        //第一次调用getInstance方法的时候实例化
        if (mySingleton == null) {
            mySingleton = new MySingleton2();
        }
        return mySingleton;
    }
}
